package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotGuest;
import com.gaohe.hotal.service.IHotGuestService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/guest")
public class HotGuestController extends BaseController
{
    @Autowired
    private IHotGuestService hotGuestService;

    /**
     * 查询客户列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:guest:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotGuest hotGuest)
    {
        startPage();
        List<HotGuest> list = hotGuestService.selectHotGuestList(hotGuest);
        return getDataTable(list);
    }

    /**
     * 导出客户列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:guest:export')")
    @Log(title = "客户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotGuest hotGuest)
    {
        List<HotGuest> list = hotGuestService.selectHotGuestList(hotGuest);
        ExcelUtil<HotGuest> util = new ExcelUtil<HotGuest>(HotGuest.class);
        util.exportExcel(response, list, "客户数据");
    }

    /**
     * 获取客户详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:guest:query')")
    @GetMapping(value = "/{guestId}")
    public AjaxResult getInfo(@PathVariable("guestId") Long guestId)
    {
        return success(hotGuestService.selectHotGuestByGuestId(guestId));
    }

    /**
     * 新增客户
     */
    @PreAuthorize("@ss.hasPermi('hotal:guest:add')")
    @Log(title = "客户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotGuest hotGuest)
    {
        return toAjax(hotGuestService.insertHotGuest(hotGuest));
    }

    /**
     * 修改客户
     */
    @PreAuthorize("@ss.hasPermi('hotal:guest:edit')")
    @Log(title = "客户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotGuest hotGuest)
    {
        return toAjax(hotGuestService.updateHotGuest(hotGuest));
    }

    /**
     * 删除客户
     */
    @PreAuthorize("@ss.hasPermi('hotal:guest:remove')")
    @Log(title = "客户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guestIds}")
    public AjaxResult remove(@PathVariable Long[] guestIds)
    {
        return toAjax(hotGuestService.deleteHotGuestByGuestIds(guestIds));
    }
}
